package com.hbhmzy.utils;

import java.net.InetSocketAddress;
import java.util.HashMap;
import java.util.Map;


public class MyMap {
    //保存用户UID, 给谁发过消息
    public static Map<Integer, Integer> onlineUsersToWho = new HashMap<>();
    //保存用户UID, IP, 端口
    public static Map<Integer, InetSocketAddress> onlineUsersInfo = new HashMap<>();


    //根据map的value获取map的key
    public static Integer getKey(Map<Integer, String> map, String value) {
        int key = 1;
        for (Map.Entry<Integer, String> entry : map.entrySet()) {
            if (value.equals(entry.getValue())) {
                key = entry.getKey();
            }
        }
        return key;
    }
}